<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!-- import Vue before Element -->
    <script src="https://unpkg.com/vue@2/dist/vue.js"></script>
    <!-- import JavaScript -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <script src="data/axios-0.18.0.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>
<body>
<div id="app">
    <h1>用户审核</h1>
    <!--    <div style="float: left;line-height: 40px;">账号/手机号:</div>-->
    <!--    <el-input-->
    <!--            placeholder="请输入"-->
    <!--            v-model="input"-->
    <!--            clearable style="width: 212px;float: left;margin-left: 15px;">-->
    <!--    </el-input>-->
    <!--    <div style="float: left;line-height: 40px;margin-left: 120px;margin-right: 16px;">状态:</div>-->
    <!--    <template>-->
    <!--        <el-select v-model="value" placeholder="请选择" style="float: left;">-->
    <!--            <el-option-->
    <!--                    v-for="item in options"-->
    <!--                    :key="item.value"-->
    <!--                    :label="item.label"-->
    <!--                    :value="item.value">-->
    <!--            </el-option>-->
    <!--        </el-select>-->

    <!--    </template>-->
    <!--    <el-row style="float: left;margin-left: 70px;">-->
    <!--        <el-button type="primary" @click="init">查询</el-button>-->
    <!--    </el-row>-->

    <div style="float: left">
        <el-row>
            <el-button size="medium">批量操作</el-button>
        </el-row>
    </div>
    <div style="float: left;margin-left: 1000px">
        <el-row>
            <el-button size="medium">通过</el-button>
        </el-row>
        <el-row>
            <el-button size="medium">驳回</el-button>
        </el-row>
    </div>

    <template>


        <el-table
                :data="tableData"
                style="width: 100%">

            <el-table-column
                    prop="name"
                    label="账号"
                    width="200">
            </el-table-column>
            <el-table-column
                    prop="nickname"
                    label="用户昵称"
                    width="200">
            </el-table-column>
            <el-table-column
                    prop="certificationDate"
                    label="认证时间"
                    width="200">
            </el-table-column>
            <el-table-column
                    prop="certificationType"
                    label="认证类型"
                    width="200">
            </el-table-column>
            <el-table-column
                    prop="authInfo"
                    label="认证信息"
                    width="200">
                <template slot-scope="scope">
                    <el-button type="text" @click="look(scope.row),dialogFormVisible = true">查看</el-button>
                </template>
            </el-table-column>
            <el-table-column
                    prop="operation"
                    label="操作"
                    width="200">
                <template slot-scope="scope">
                    <el-button type="text" @click="operation(scope.row.id,'通过')">通过</el-button>
                    <el-button type="text" @click="operation(scope.row.id,'驳回')">驳回</el-button>
                </template>
            </el-table-column>

        </el-table>

        <el-dialog title="实名认证" :visible.sync="dialogFormVisible">
            <el-form :model="form">
                <el-form-item label="姓名:" :label-width="formLabelWidth">
                    <span>{{form.name}}</span>
                </el-form-item>
                <el-form-item label="身份证号:" :label-width="formLabelWidth">
                    <span>{{form.idcard}}</span>
                </el-form-item>


                <el-form-item label="身份证正面:" :label-width="formLabelWidth">
                    <el-image
                            style="width: 400px; height: 200px"
                            :src="form.imgasrc"></el-image>
                </el-form-item>

                <el-form-item label="身份证反面:" :label-width="formLabelWidth">
                    <el-image
                            style="width: 400px; height: 200px"
                            :src="form.imgbsrc"></el-image>
                </el-form-item>


            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisible = false,operation2('驳回')">驳 回</el-button>
                <el-button type="primary" @click="dialogFormVisible = false,operation2('通过')">通 过
                </el-button>
            </div>
        </el-dialog>

    </template>
    <!--分页插件-->
    <div class="pagination-container">
        <el-pagination
                class="pagiantion"
                @current-change="handleCurrentChange"
                :current-page="pagination.currentPage"
                :page-size="pagination.pageSize"
                layout="total, prev, pager, next, jumper"
                :total="pagination.total"
                background
                layout="prev, pager, next"
                :total="1000">
        </el-pagination>
    </div>


</div>


</body>
<script>
    var Main = {
        data() {
            return {
                tableData: [],/*列表展示数据*/

                pagination: {
                    //分页相关模型数据
                    currentPage: 1,	//当前页码
                    pageSize: 8,	//每页显示的记录数
                    total: 0,		//总记录数
                },

                dialogFormVisible: false,
                form: {
                    id:'',
                    name: '',
                    idcard: '',
                    imgasrc: '',
                    imgbsrc: '',
                    date1: '',
                    date2: '',
                    delivery: false,
                    type: [],
                    resource: '',
                    desc: ''
                },
                formLabelWidth: '120px',

            }
        },
        /*一打开页面就执行方法*/
        created() {
            this.init();
        },
        /*方法*/
        methods: {
            init() {
                axios({
                    method: 'get',
                    url: '/admin/userAuditList.html/' + this.pagination.currentPage + '/' + this.pagination.pageSize
                }).then(res => {
                    console.log(res.data.data)
                    this.pagination.total = res.data.data.total;
                    this.pagination.currentPage = res.data.data.current;
                    this.pagination.pagesize = res.data.data.size;
                    this.tableData = res.data.data.records;
                })
            },
            /*切换页码*/
            handleCurrentChange(currentPage) {
                this.pagination.currentPage = currentPage
                this.init()
            },
            /*通过跟驳回操作*/
            operation(id, status) {
                status = status === '通过' ? 'batchPass' : 'batchReject';
                /*id*/
                var ids = [id];
                axios.put('/admin/' + status + '.html?id=' + ids).then(res => {
                    this.init();
                    this.successMessage(res.data.data);
                })
            },
            /*查看信息后中转*/
            operation2(status){
                this.operation(this.form.id, status);
            },
            /*查看*/
            look(certification) {
                this.form.name = certification.realName;
                this.form.idcard = certification.idcard;
                this.form.imgasrc = certification.idcardAImg;
                this.form.imgbsrc = certification.idcardBImg;
                this.form.id=certification.id;
            },
            /*提示消息*/
            successMessage(data) {
                this.$message({
                    message: data,
                    type: 'success'
                });
            },
        }

    }
    var Ctor = Vue.extend(Main)
    new Ctor().$mount('#app')
</script>
</html>